// pages/start/start.js
var app = getApp();
Page({
  data: {
    userInfo:'',
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    remind: '加载中',
    angle: 0,
    year: 2019,
  },
  login(){
    var that=this;
    console.log('点击了立即体验')
    wx.getUserProfile({
      desc: '授权开始使用',
      success(res){
        let user=res.userInfo
        //把用户信息缓存到本地
        wx.setStorageSync('user',user)
        console.log('用户信息',user)
        that.setData({
          userInfo:user
        })
        console.log('授权成功',res)
        wx.switchTab({
          url: '../mine/mine',
        })
      },
      fail(res){
        console.log('授权失败',res)
      }
    })
  },
  
  onLoad: function() {
    var that = this;
    that.setData({
      year: new Date().getFullYear()
    });
    let user = wx.getStorageSync('user')
    console.log('进入小程序的index页面获取缓存',user)
  },
  bindGetUserInfo: function(e) {
    console.log(e.detail.userInfo)
  },
  onShow: function () {
  },
  onReady: function () {
    var _this = this;
    setTimeout(function () {
      _this.setData({
        remind: ''
      });
    }, 1000);
  },
});